package cn.kgc.service;

import cn.kgc.dao.UserMapper;
import cn.kgc.entity.User;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Rock
 * @create 2020-03-03 20:22
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;

    public User login(User user) {
        return userMapper.login(user);
    }

    public PageInfo<User> queryByNameAndRole(User user, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum,pageSize);
        List<User> list = userMapper.queryByNameAndRole(user);
        return new PageInfo<User>(list);
    }

    public List<User> queryByUserCode(String userCode) {
        return userMapper.queryByUserCode(userCode);
    }

    public Integer save(User user) {
        return userMapper.save(user);
    }

    public User queryById(Integer id) {
        return userMapper.queryById(id);
    }

    public Integer updatePassword(User user) {
        return userMapper.updatePassword(user);
    }

    public Integer update(User user) {
        return userMapper.update(user);
    }

    public Integer delete(Integer userId) {
        return userMapper.delete(userId);
    }

    public Integer updateStatus(Integer id) {
        return userMapper.updateStatus(id);
    }
}
